package com.design.composite.draw;

import java.util.ArrayList;
import java.util.List;

// 组合图形类，实现了图形接口
class CompositeShape implements Shape {
    private List<Shape> shapes = new ArrayList<>();

    public void addShape(Shape shape) {
        shapes.add(shape);
    }

    @Override
    public void draw() {
        System.out.println("Drawing CompositeShape");
        for (Shape shape : shapes) {
            shape.draw();
        }
    }

    @Override
    public void move(int x, int y) {
        System.out.println("Moving CompositeShape to (" + x + ", " + y + ")");
        for (Shape shape : shapes) {
            shape.move(x, y);
        }
    }
}
